﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using clf.weighing.entity;

namespace weighing
{
    /// <summary>
    /// 今天数据的删除显示转换器
    /// </summary>
    public class BillDelTodayConveter : System.Windows.Data.IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            //开发者
            if (App.CurrentUser.roleType == (int)UserRoleType.Developer) return Visibility.Visible;
            WeighingBillVo bill = value as WeighingBillVo;
            string permissionKey;
            if (bill.Status == 1)
            {
                permissionKey = PermissionKeys.BillDelFinish;
            }
            else
            {
                permissionKey = PermissionKeys.BillDel;
            }
            //未传参
            if (string.IsNullOrEmpty(permissionKey)) return Visibility.Collapsed;
        
            return UserDao.Instance.HasPermission(permissionKey) ? Visibility.Visible : Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
